﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DirectorRoomHelper.Models;
using System.Collections.ObjectModel;

namespace DirectorRoomHelper.Controls
{
    /// <summary>
    /// Interaction logic for CatalogTileViewControl.xaml
    /// </summary>
    public partial class TileViewControl : UserControl
    {
        public static readonly RoutedEvent ItemActionEvent;

        static TileViewControl()
        {
            TileViewControl.ItemActionEvent = 
                EventManager.RegisterRoutedEvent("ItemAction", RoutingStrategy.Bubble, 
                    typeof(RoutedEventHandler), typeof(TileViewControl));
        }

        public event RoutedEventHandler ItemAction
        {
            add { AddHandler(ItemActionEvent, value); }
            remove { RemoveHandler(ItemActionEvent, value); }
        }

        public TileViewControl()
        {
            InitializeComponent();
            this.DataContext = this;
            CurrentPath = string.Empty;
        }

        private void ListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            RaiseEvent(new RoutedEventArgs(TileViewControl.ItemActionEvent, sender));
        }

        public ObservableCollection<TileViewItem> Items { get; set; }
        public int TopParentID { get; set; }
        public string CurrentPath { get; set; }
    }
}
